﻿using System;

namespace calculator_Control
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入第一个数字");
            string Num1 = Console.ReadLine();
            double num1 = Double.Parse(Num1);

             Console.WriteLine("请输入第二个数字");
            string Num2 = Console.ReadLine();
            double num2 = Double.Parse(Num2);

            Console.WriteLine("选择运算符");
            char Op = (char)Console.Read();

            Calculator ca = new Calculator();
            ca.Calculate(num1, num2, Op);
            Console.ReadLine();
        }
    }
    class Calculator {
        public void Calculate(double num1, double num2, char op) {      
            double result = 0;
            switch (op) {
                case'+':
                    result = num1 + num2;
                    Console.WriteLine("结果为"+result);
                    break;
                case '-':
                    result = num1 - num2;
                    Console.WriteLine("结果为" + result);
                    break;
                case '*':
                    result = num1 * num2;
                    Console.WriteLine("结果为" + result);
                    break;
                case '/':
                    if (num2 == 0) Console.WriteLine("被除数不能为0");
                    else
                    {
                        result = num1 / num2;
                        Console.WriteLine("结果为" + result);
                    }
                    break;
                case '%':
                  result = num1 % num2;
                    Console.WriteLine("结果为" + result);
                    break;
                default:
                    Console.WriteLine("输入符号错误");
                    break;
            }
        
        }
    }
}
